#include "jolfs/inode.h"

using namespace jolfs;

INode* INode::createChild(const std::string& name,
			  mode_t mode, INode::type_t type, filesize_t size)
{
  // TODO: check the type of the current node.
  

  // check if the child is already allocated.
  if(child_) {
    // check if does not already exists
    Map::iterator it = child_->find(name);
    if(it != child_->end()) return NULL;
  } else {
    child_ = new Map;
  }
  
  // not exists, so we can create an entry.
  INode* tmp = new INode(name, mode, type, size);
  child_->insert(std::make_pair(name, tmp));

  return tmp;
}
